package cn.jaye.fabric.common.config;

import cn.jaye.fabric.common.interceptor.SecurityInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @author Jaye
 * @create 2018-04-04 16:05
 */
@Configuration
public class MVCConfig extends WebMvcConfigurerAdapter {
    @Bean
    public SecurityInterceptor securityInterceptor() {
        return new SecurityInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(securityInterceptor())
                .excludePathPatterns("/static/*")
                .excludePathPatterns("/error")
                .excludePathPatterns("/user/register")
                .excludePathPatterns("/user/login")
                .excludePathPatterns("/ping")
//                .excludePathPatterns("/test/**")
                .addPathPatterns("/**");
        super.addInterceptors(registry);
    }

}